Add OpenCode Go usage API support - #2879
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs real behavior proof before merge. Reviewed August 19, 2026, 8:51 AM ET / 12:51 UTC. ClawSweeper reviewWhat this changesThis PR adds an API-key source for OpenCode Go usage, overlays API quota windows onto local cost history, retains cookie-derived balance data, and updates provider documentation and tests. Merge readiness⛔ Blocked until real behavior proof from a real setup is added - 6 items remain Current main does not support the OpenCode Go usage API, so this PR remains necessary, but it needs a scoped-source correction, maintainer product sponsorship for the new credential surface, and real authenticated proof before merge. Priority: P2 Review scores
Verification
How this fits togetherCodexBar’s OpenCode Go provider turns local SQLite history, browser-cookie usage, and API data into one usage snapshot for the menu bar and CLI. Source ordering matters because cookie web usage is workspace-scoped while the new API key is not. flowchart LR
A[Local SQLite history] --> D[OpenCode Go source selection]
B[Workspace cookie session] --> D
C[API key] --> D
D --> E[Quota and balance overlay]
E --> F[Usage snapshot]
F --> G[Menu bar and CLI]
Decision needed
Why: This adds a new credential-backed provider capability, and tests cannot establish the desired product boundary for account-agnostic API data versus workspace-scoped usage. Before merge
Findings
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: If maintainers sponsor the capability, restrict API overlays to unscoped usage, retain workspace-scoped Web → Local → API semantics, add regression coverage, and obtain a redacted real-account trace. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: use Auto mode with a workspace override, local history, and an API key after the web attempt cannot authenticate; the local strategy calls the API overlay before the separate API fallback. Is this the best way to solve the issue? No: the unscoped overlay approach is reasonable, but the same overlay must not run in a workspace-scoped request where the API key is account-agnostic. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 453174fe13ee. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (9 earlier review cycles; latest 8 shown)
|
|
Fixed the failing macOS shard in signed commit The implementation intentionally adds OpenCode Go to the descriptor-derived API-key debug registry; the architecture gate's exact expected list had not been updated. The corrected gate now passes locally. Verification:
@clawsweeper re-review — Akshay / Codex |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
b839f54 to
2f42b83
Compare
|
Rebased this draft PR onto current upstream The prior aggregate failure was draft policy rather than a provider regression: required macOS tests were deferred while the PR was draft, so the aggregate correctly reported incomplete. GitHub now reports the rebased branch mergeable. — Akshay / Codex |
|
Post-rebase verification is complete on head
GitHub reports the PR mergeable. ClawSweeper found no actionable implementation or security findings; its remaining gate is an authenticated OpenCode Go runtime trace, which requires contributor-provided account credentials and must be redacted before posting. — Akshay / Codex |
2f42b83 to
d467b54
Compare
|
Rebased onto current The integration preserves #2987’s estimated-confidence and manual-token behavior while adding the authenticated API overlay and retaining Zen balance. The original worktree’s unrelated local edits were not touched. SwiftFormat and Tracking issue: #3065. — Akshay / Codex |
|
Glad to see this merged. Cookies weren't working for me. I pulled and built this branch and it's been working great. Thanks @akshayprabhu200 @steipete ! |
Summary
GET /zen/go/v1/usageAPI for rolling, weekly, and monthly utilizationOPENCODE_API_KEYfrom CodexBar settings, provider config, or the environmentWhy
OpenCode Go now exposes an authenticated public usage endpoint. CodexBar previously depended on local estimates or private web-session requests, even when a stable API key was available.
Behavior and compatibility
Proof
swift test --filter OpenCodeGo: 108 tests passed across 11 OpenCode Go suites on the initial implementation.make check: passed after the review fix (formatting, SwiftLint, manifests, signing/package gates, and documentation links).No personal usage data or credentials are included in this change. A live authenticated endpoint capture is not attached because no
OPENCODE_API_KEYis available in this environment; all included network proof is deterministic request-contract coverage.Closes anomalyco/opencode#31084